package com.hxd.otc.module.wallet.presenter;

import android.support.annotation.NonNull;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.base.BaseRecyclerPresenter;
import com.hxd.otc.module.wallet.adapter.WalletCurrencyAdapter;
import com.hxd.otc.module.wallet.bean.WalletCurrencyBean;
import com.hxd.otc.module.wallet.contract.WalletCurrencyContract;
import com.hxd.otc.module.wallet.model.WalletModel;
import com.hxd.otc.net.BaseObserver;
import com.hxd.otc.utils.LogUtils;

import java.util.List;

/**
 * Created by lzy on 2018/9/21 0021.
 * description ${钱包币种Presenter}
 */
public class WalletCurrencyPresenter extends BaseRecyclerPresenter<WalletCurrencyContract.IView,
        WalletCurrencyAdapter, WalletCurrencyBean> implements WalletCurrencyContract.IPresenter {


    private WalletModel walletModel;
    List<WalletCurrencyBean> norWalletInfoBeans;
    List<WalletCurrencyBean> otcWalletInfoBeans;
    private boolean isNorInfo;

    public void setNorInfo(boolean norInfo) {
        isNorInfo = norInfo;
    }

    public WalletCurrencyPresenter(WalletCurrencyContract.IView iView) {
        super(iView);
        walletModel = WalletModel.getInstance();
    }

    @Override
    public void loadData(final boolean isRefresh) {

        walletModel.getWalletAccountInfo(new BaseObserver<List<WalletCurrencyBean>>() {
            @Override
            public void onNext(@NonNull String msg, List<WalletCurrencyBean> beans) {
                onLoadDataSuccess(isRefresh, beans);
                if (isNorInfo) {
                    norWalletInfoBeans = beans;
                    LogUtils.e("=====norWalletInfoBeans============="+norWalletInfoBeans.toString());
                } else {
                    otcWalletInfoBeans = beans;
                    LogUtils.e("=====otcWalletInfoBeans============="+otcWalletInfoBeans.toString());
                }
                mView.onSuccedd();
            }

            @Override
            public void onError(int errType, @NonNull String errMessage) {
                onLoadDataFail(isRefresh, errMessage);
            }
        }, mView.<BaseBean<List<WalletCurrencyBean>>>bindAutoDispose(), isNorInfo);

    }


    @Override
    public List<WalletCurrencyBean> getOtcWalletInfoBeans() {
        return otcWalletInfoBeans;
    }

    @Override
    public List<WalletCurrencyBean> getNorWalletInfoBeans() {
        return norWalletInfoBeans;
    }
}
